<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <script>
       //注册事件监听
       function connectWebViewJavascriptBridge(callback) {
           if (window.WebViewJavascriptBridge) {
               WebViewJavascriptBridge.init();
               callback(WebViewJavascriptBridge)
           } else {
               document.addEventListener(
                   'WebViewJavascriptBridgeReady'
                   , function() {
                       WebViewJavascriptBridge.init();
                       callback(WebViewJavascriptBridge)
                   },
                   false
               );
           }
       }
       //注册回调函数，第一次连接时调用 初始化函数
       connectWebViewJavascriptBridge(function(bridge) {
           bridge.registerHandler("jsFunction", function(data, responseCallback) {
                 document.getElementById("content").innerHTML = ("data from Java: = " + data);
                 var responseData = "Javascript Says Right back aka!";
                 responseCallback(responseData);
           });
       })
    </script>
</head>
<body>
<div>
    <input id="cmd_input" name="cmd_frame">
    <br/>
    <button id="cmd_btn">执行cmd</button>
</div>


<div id="content">

</div>

</body>

<script type="text/javascript">
        var content = document.getElementById("content");
        document.getElementById("cmd_btn").onclick = function(){
            var cmd = document.getElementById("cmd_input").value
            window.WebViewJavascriptBridge.callHandler(
               'execCmd'
               ,cmd
               , function(responseData) {
                    content.innerHTML = ("exec cmd result: = " + responseData);
               }
           );
        };
    </script>
</html>